package pack0826;

import java.util.Objects;

public class Users implements Comparable<Users> {
    private Integer id;
    private String name;
    private Double tizhong;

    //初始化
    public Users() {

    }

    public Users(Integer id, String name, Double tizhong) {
        this.id = id;
        this.name = name;
        this.tizhong = tizhong;
    }

    //封装
    public Integer getId(){
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getTizhong() {
        return tizhong;
    }

    public void setTizhong(Double tizhong) {
        this.tizhong = tizhong;
    }

    //重写equals

    @Override

    public boolean equals(Object o) {
        int my = this.getId();
        Users u = (Users) o;
        int t = u.getId();
        return my == t;
    }

    public int compareTo(Users o) {
        return (int) (this.getId() - o.getId());
    }

    @Override
    public String toString() {
        return "Users{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", tizhong=" + tizhong +
                '}';
    }
}
